# Customise this file, documentation can be found here:
# https://github.com/fastlane/fastlane/tree/master/fastlane/docs
# All available actions: https://docs.fastlane.tools/actions
# can also be listed using the `fastlane actions` command

# Change the syntax highlighting to Ruby
# All lines starting with a # are ignored when running `fastlane`

# If you want to automatically update fastlane if a new version is available:
# update_fastlane

# This is the minimum version number required.
# Update this, if you use features of a newer version
fastlane_version "2.59.0"

default_platform :ios

platform :ios do
  #更新配置文件
  desc "update profile of appstore"
  lane :update_profile do
    
    match(type: "appstore",app_identifier: "com.vintners.ios",force_for_new_devices: true)
    match(type: "adhoc",app_identifier: "com.vintners.ios",force_for_new_devices: true)
    match(type: "development",app_identifier: "com.vintners.ios",force_for_new_devices: true)

  end

  #同步配置文件
  desc "synchronize profile of appstore"
  lane :syn_profile do
    
    match(type: "appstore",readonly: true)
    match(type: "adhoc",readonly: true)
    match(type: "development",readonly: true)

  end

  #更新pods
  before_all do
    system "security unlock-keychain -p '  '"
    #增加build number
    #increment_build_number
    cocoapods

  end

  desc "Runs all the tests"
  lane :test do
    scan
  end

  desc "Submit a new Beta Build to Apple TestFlight"
  desc "This will also make sure the profile is up to date"
  lane :beta do
    #match(type: "adhoc") # more information: https://codesigning.guide
    # gym(scheme: "vintners") # Build your app - more options available
    # pilot
    # match(type: "appstore",readonly: true)
    match(type: "adhoc",readonly: true)
    # match(type: "development",readonly: true)
    gym(scheme: "vintners",export_method: "ad-hoc")
    pgyer(api_key: "5db5a36fac86fd69ac35c47a26770646", user_key: "bea9f0f57037ed1be7afb2139d28b000")

    # sh "your_script.sh"
    # You can also use other beta testing services here (run `fastlane actions`)
  end

  desc "Deploy a new version to the App Store"
  lane :release do
    # match(type: "appstore")
    # snapshot
    gym(scheme: "vintners") # Build your app - more options available
    deliver(force: true)
    # frameit
  end

  desc "upload pgyer"
  lane :upload_pgyer do
    pgyer(api_key: "5db5a36fac86fd69ac35c47a26770646", user_key: "bea9f0f57037ed1be7afb2139d28b000")
  end

  # You can define as many lanes as you want

  after_all do |lane|
    # This block is called, only if the executed lane was successful

    # slack(
    # message: "Successfully deployed new App Update."
    #)
  end

  error do |lane, exception|
    # slack(
    #  message: exception.message,
    #  success: false
    # )
  end
end


# More information about multiple platforms in fastlane: https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Platforms.md
# All available actions: https://docs.fastlane.tools/actions

# fastlane reports which actions are used. No personal data is recorded. 
# Learn more at https://github.com/fastlane/fastlane#metrics
